﻿using Bll;
using Help;
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Myproject.BSM.Ashx.Base
{
    /// <summary>
    /// Changeemail 的摘要说明
    /// </summary>
    public class Changeemail : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string oldpwd = context.Request.Params["pc_base_ChangeEmail_pwd"].Trim();
            string email = context.Request.Params["pc_base_ChangeEmail_email"].Trim();
            string adminID = context.Request.Params["pc_base_ChangeEmail_adminID"].Trim();
            AdminModel model = new AdminBLL().GetModel(int.Parse(adminID));
            if (model != null)
            {
                if (model.AdminPwd == oldpwd)
                {
                    model.Email = email;
                    if (new AdminBLL().Update(model))
                    {
                        context.Response.Write(ReturnJsonHelp.BJUIajaxJson(200, "修改绑定邮箱成功！", "", "", "", true, "", ""));
                    }
                    else
                    {
                        context.Response.Write(ReturnJsonHelp.BJUIajaxJson(300, "修改绑定邮箱失败！", "", "", "", true, "", ""));
                    }
                }
                else
                {
                    context.Response.Write(ReturnJsonHelp.BJUIajaxJson(300, "修改绑定邮箱失败,密码错误！", "", "", "", true, "", ""));
                }
            }
            else
            {
                context.Response.Write(ReturnJsonHelp.BJUIajaxJson(300, "修改绑定邮箱失败,参数错误！", "", "", "", true, "", ""));
            }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}